/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import model.PengendaliMahasiswa;
import model.Yudisium;

/**
 *
 * @author tashiba
 */
public class FormMahasiswa extends JPanel {

    private JTextField textnama;
    private JLabel lblnama;
    private JTextField textnim;
    private JLabel lblnim;
    private JTextField texttelpEmail;
    private JLabel lbltelpEmail;
    private JTextField textperiode;
    private JLabel lblperiode;
    private JTextField texthari;
    private JLabel lblhari;
    private JTextField texttanggal;
    private JLabel lbltanggal;
    private JLabel lblprodi;
    private JRadioButton radioTE;
    private JRadioButton radioTM;
    private JRadioButton radioTI;
    private JRadioButton radioMAT;
    private JLabel lblLampiran;
    private JCheckBox daftarNilai;
    private JLabel lbldaftarNilai;
    private JCheckBox naskahTA;
    private JLabel lblnaskahTA;
    private JCheckBox bebasPinjLab;
    private JLabel lblbebasPinjLab;
    private JCheckBox bebasPinjDosen;
    private JLabel lblbebasPinjDosen;
    private JCheckBox KP;
    private JLabel lblKP;
    private JCheckBox toefl;
    private JLabel lbltoefl;
    private JCheckBox pengesahanTA;
    private JLabel lblPengesahanTA;
    private JCheckBox sistemPoin;
    private JLabel lblSistemPoin;
    private JCheckBox RBM;
    private JLabel lblRBM;
    private JButton tombolSimpan;
    private JButton tombolBatal;

    public FormMahasiswa() {
        inisialisasi();
    }

    public JTextField getTextnama() {
        return textnama;
    }

    public void setTextnama(JTextField textnama) {
        this.textnama = textnama;
    }

    public JLabel getLblnama() {
        return lblnama;
    }

    public void setLblnama(JLabel lblnama) {
        this.lblnama = lblnama;
    }

    public JTextField getTextnim() {
        return textnim;
    }

    public void setTextnim(JTextField textnim) {
        this.textnim = textnim;
    }

    public JLabel getLblnim() {
        return lblnim;
    }

    public void setLblnim(JLabel lblnim) {
        this.lblnim = lblnim;
    }

    public JTextField getTexttelpEmail() {
        return texttelpEmail;
    }

    public void setTexttelpEmail(JTextField texttelpEmail) {
        this.texttelpEmail = texttelpEmail;
    }

    public JLabel getLbltelpEmail() {
        return lbltelpEmail;
    }

    public void setLbltelpEmail(JLabel lbltelpEmail) {
        this.lbltelpEmail = lbltelpEmail;
    }

    public JTextField getTextperiode() {
        return textperiode;
    }

    public void setTextperiode(JTextField textperiode) {
        this.textperiode = textperiode;
    }

    public JLabel getLblperiode() {
        return lblperiode;
    }

    public void setLblperiode(JLabel lblperiode) {
        this.lblperiode = lblperiode;
    }

    public JTextField getTexthari() {
        return texthari;
    }

    public void setTexthari(JTextField texthari) {
        this.texthari = texthari;
    }

    public JLabel getLblhari() {
        return lblhari;
    }

    public void setLblhari(JLabel lblhari) {
        this.lblhari = lblhari;
    }

    public JTextField getTexttanggal() {
        return texttanggal;
    }

    public void setTexttanggal(JTextField texttanggal) {
        this.texttanggal = texttanggal;
    }

    public JLabel getLbltanggal() {
        return lbltanggal;
    }

    public void setLbltanggal(JLabel lbltanggal) {
        this.lbltanggal = lbltanggal;
    }

    public JLabel getLblprodi() {
        return lblprodi;
    }

    public void setLblprodi(JLabel lblprodi) {
        this.lblprodi = lblprodi;
    }

    public JRadioButton getRadioTE() {
        return radioTE;
    }

    public void setRadioTE(JRadioButton radioTE) {
        this.radioTE = radioTE;
    }

    public JRadioButton getRadioTM() {
        return radioTM;
    }

    public void setRadioTM(JRadioButton radioTM) {
        this.radioTM = radioTM;
    }

    public JRadioButton getRadioTI() {
        return radioTI;
    }

    public void setRadioTI(JRadioButton radioTI) {
        this.radioTI = radioTI;
    }

    public JRadioButton getRadioMAT() {
        return radioMAT;
    }

    public void setRadioMAT(JRadioButton radioMAT) {
        this.radioMAT = radioMAT;
    }

    public JLabel getLblLampiran() {
        return lblLampiran;
    }

    public void setLblLampiran(JLabel lblLampiran) {
        this.lblLampiran = lblLampiran;
    }

    public JCheckBox getDaftarNilai() {
        return daftarNilai;
    }

    public void setDaftarNilai(JCheckBox daftarNilai) {
        this.daftarNilai = daftarNilai;
    }

    public JLabel getLbldaftarNilai() {
        return lbldaftarNilai;
    }

    public void setLbldaftarNilai(JLabel lbldaftarNilai) {
        this.lbldaftarNilai = lbldaftarNilai;
    }

    public JCheckBox getNaskahTA() {
        return naskahTA;
    }

    public void setNaskahTA(JCheckBox naskahTA) {
        this.naskahTA = naskahTA;
    }

    public JLabel getLblnaskahTA() {
        return lblnaskahTA;
    }

    public void setLblnaskahTA(JLabel lblnaskahTA) {
        this.lblnaskahTA = lblnaskahTA;
    }

    public JCheckBox getBebasPinjLab() {
        return bebasPinjLab;
    }

    public void setBebasPinjLab(JCheckBox bebasPinjLab) {
        this.bebasPinjLab = bebasPinjLab;
    }

    public JLabel getLblbebasPinjLab() {
        return lblbebasPinjLab;
    }

    public void setLblbebasPinjLab(JLabel lblbebasPinjLab) {
        this.lblbebasPinjLab = lblbebasPinjLab;
    }

    public JCheckBox getBebasPinjDosen() {
        return bebasPinjDosen;
    }

    public void setBebasPinjDosen(JCheckBox bebasPinjDosen) {
        this.bebasPinjDosen = bebasPinjDosen;
    }

    public JLabel getLblbebasPinjDosen() {
        return lblbebasPinjDosen;
    }

    public void setLblbebasPinjDosen(JLabel lblbebasPinjDosen) {
        this.lblbebasPinjDosen = lblbebasPinjDosen;
    }

    public JCheckBox getKP() {
        return KP;
    }

    public void setKP(JCheckBox KP) {
        this.KP = KP;
    }

    public JLabel getLblKP() {
        return lblKP;
    }

    public void setLblKP(JLabel lblKP) {
        this.lblKP = lblKP;
    }

    public JCheckBox getToefl() {
        return toefl;
    }

    public void setToefl(JCheckBox toefl) {
        this.toefl = toefl;
    }

    public JLabel getLbltoefl() {
        return lbltoefl;
    }

    public void setLbltoefl(JLabel lbltoefl) {
        this.lbltoefl = lbltoefl;
    }

    public JCheckBox getPengesahanTA() {
        return pengesahanTA;
    }

    public void setPengesahanTA(JCheckBox pengesahanTA) {
        this.pengesahanTA = pengesahanTA;
    }

    public JLabel getLblPengesahanTA() {
        return lblPengesahanTA;
    }

    public void setLblPengesahanTA(JLabel lblPengesahanTA) {
        this.lblPengesahanTA = lblPengesahanTA;
    }

    public JCheckBox getSistemPoin() {
        return sistemPoin;
    }

    public void setSistemPoin(JCheckBox sistemPoin) {
        this.sistemPoin = sistemPoin;
    }

    public JLabel getLblSistemPoin() {
        return lblSistemPoin;
    }

    public void setLblSistemPoin(JLabel lblSistemPoin) {
        this.lblSistemPoin = lblSistemPoin;
    }

    public JCheckBox getRBM() {
        return RBM;
    }

    public void setRBM(JCheckBox RBM) {
        this.RBM = RBM;
    }

    public JLabel getLblRBM() {
        return lblRBM;
    }

    public void setLblRBM(JLabel lblRBM) {
        this.lblRBM = lblRBM;
    }

    public JButton getTombolSimpan() {
        return tombolSimpan;
    }

    public void setTombolSimpan(JButton tombolSimpan) {
        this.tombolSimpan = tombolSimpan;
    }

    public JButton getTombolBatal() {
        return tombolBatal;
    }

    public void setTombolBatal(JButton tombolBatal) {
        this.tombolBatal = tombolBatal;
    }

    public void inisialisasi() {
        setLayout(null);

        JLabel judul = new JLabel("FORMULIR PENDAFTARAN YUDISIUM");
        judul.setBounds(350, 20, 700, 50);
        this.add(judul);
        lblnama=new JLabel("Nama");
        lblnama.setBounds(50, 120, 80, 20);
        this.add(lblnama);

        textnama=new JTextField();
        textnama.setBounds(130, 120, 200, 20);
        this.add(textnama);

        lblnim=new JLabel("NIM");
        lblnim.setBounds(50, 150, 80, 20);
        this.add(lblnim);

        textnim=new JTextField();
        textnim.setBounds(130, 150, 150, 20);
        this.add(textnim);

        lbltelpEmail=new JLabel("Telp/Email");
        lbltelpEmail.setBounds(50, 180, 80, 20);
        this.add(lbltelpEmail);

        texttelpEmail=new JTextField();
        texttelpEmail.setBounds(130, 180, 200, 20);
        this.add(texttelpEmail);

        lblprodi=new JLabel("Prodi");
        lblprodi.setBounds(50, 210, 120, 20);
        this.add(lblprodi);

        lblperiode=new JLabel("Mendaftarkan Yudisium periode bulan                                  yang diselenggarakan pada : ");
        lblperiode.setBounds(50, 270, 490, 20);
        this.add(lblperiode);

        textperiode=new JTextField();
        textperiode.setBounds(270, 270, 85, 20);
        this.add(textperiode);

        lblhari=new JLabel("Hari");
        lblhari.setBounds(50, 300, 80, 20);
        this.add(lblhari);

        texthari=new JTextField();
        texthari.setBounds(130, 300, 100, 20);
        this.add(texthari);

        lbltanggal=new JLabel("Tanggal");
        lbltanggal.setBounds(50, 330, 80, 20);
        this.add(lbltanggal);

        texttanggal=new JTextField();
        texttanggal.setBounds(130, 330, 200, 20);
        this.add(texttanggal);

        ButtonGroup jp = new ButtonGroup();
        radioTI=new JRadioButton("TI");
        radioTI.setBounds(130, 210, 50, 20);
        jp.add(radioTI);
        radioTI.setEnabled(true);
        this.add(radioTI);


        radioTE=new JRadioButton("TE");
        radioTE.setBounds(190, 210, 50, 20);
        jp.add(radioTE);
        radioTE.setEnabled(true);
        this.add(radioTE);

        radioTM=new JRadioButton("TM");
        radioTM.setBounds(250, 210, 50, 20);
        jp.add(radioTM);
        radioTM.setEnabled(true);
        this.add(radioTM);

        radioMAT=new JRadioButton("MAT");
        radioMAT.setBounds(310, 210, 50, 20);
        jp.add(radioMAT);
        radioMAT.setEnabled(true);
        this.add(radioMAT);

        lblLampiran=new JLabel("Adapun syarat pendaftaran yang saya lampirkan berupa : ");
        lblLampiran.setBounds(600, 90, 400, 20);
        this.add(lblLampiran);

        daftarNilai=new JCheckBox();
        daftarNilai.setBounds(600, 120, 30, 20);
        daftarNilai.setEnabled(true);
        this.add(daftarNilai);

        lbldaftarNilai=new JLabel("Daftar nilai yang telah disetujui oleh Dosen Pembimbing Akademik");
        lbldaftarNilai.setBounds(630, 120, 450, 20);
        this.add(lbldaftarNilai);

        naskahTA=new JCheckBox();
        naskahTA.setBounds(600, 150, 30, 20);
        naskahTA.setEnabled(true);
        this.add(naskahTA);

        lblnaskahTA=new JLabel("Satu (1) naskah TA / Skripsi sudah dijilid dan ditandatangani oleh Dekan + Softcopy");
        lblnaskahTA.setBounds(630, 150, 500, 20);
        this.add(lblnaskahTA);

        bebasPinjLab=new JCheckBox();
        bebasPinjLab.setBounds(600, 180, 30, 20);
        bebasPinjLab.setEnabled(true);
        this.add(bebasPinjLab);

        lblbebasPinjLab=new JLabel("Surat keterangan bebas pinjaman dari Laboratorium Jurusan");
        lblbebasPinjLab.setBounds(630, 180, 500, 20);
        this.add(lblbebasPinjLab);

        bebasPinjDosen=new JCheckBox();
        bebasPinjDosen.setBounds(600, 210, 30, 20);
        bebasPinjDosen.setEnabled(true);
        this.add(bebasPinjDosen);

        lblbebasPinjDosen=new JLabel("Surat keterangan bebas pinjaman dari Dosen-dosen Jurusan");
        lblbebasPinjDosen.setBounds(630, 210, 500, 20);
        this.add(lblbebasPinjDosen);

        KP=new JCheckBox();
        KP.setBounds(600, 240, 30, 20);
        KP.setEnabled(true);
        this.add(KP);

        lblKP=new JLabel("Bukti penyerahan laporan Kerja Praktek");
        lblKP.setBounds(630, 240, 500, 20);
        this.add(lblKP);

        toefl=new JCheckBox();
        toefl.setBounds(600, 270, 30, 20);
        toefl.setEnabled(true);
        this.add(toefl);

        lbltoefl=new JLabel("Fotocopy Keterangan TOEFL / Test Kompetensi Bahasa Inggris (TKBI)");
        lbltoefl.setBounds(630, 270, 500, 20);
        this.add(lbltoefl);

        pengesahanTA=new JCheckBox();
        pengesahanTA.setBounds(600, 300, 30, 20);
        pengesahanTA.setEnabled(true);
        this.add(pengesahanTA);

        lblPengesahanTA=new JLabel("Fotocopy Lembar Pengesahan Tugas Akhir (Khusus Prodi TI)");
        lblPengesahanTA.setBounds(630, 300, 500, 20);
        this.add(lblPengesahanTA);

        sistemPoin=new JCheckBox();
        sistemPoin.setBounds(600, 330, 30, 20);
        sistemPoin.setEnabled(true);
        this.add(sistemPoin);

        lblSistemPoin=new JLabel("Sistem Poin (mahasiswa angkatan >= 2008)");
        lblSistemPoin.setBounds(630, 330, 500, 20);
        this.add(lblSistemPoin);

        RBM=new JCheckBox();
        RBM.setBounds(600, 360, 30, 20);
        RBM.setEnabled(true);
        this.add(RBM);

        lblRBM=new JLabel("Bukti Penyerahan RBM (khusus Prodi TM)");
        lblRBM.setBounds(630, 360, 500, 20);
        this.add(lblRBM);

        JPanel save = new JPanel();
        tombolSimpan=new JButton();
        tombolSimpan.setBounds(400, 450, 80, 20);
        tombolSimpan.setText("Simpan");
        save.add(tombolSimpan);
        this.add(tombolSimpan);

        JPanel cancel = new JPanel();
        tombolBatal=new JButton();
        tombolBatal.setBounds(500, 450, 80, 20);
        tombolBatal.setText("Batal");
        cancel.add(tombolBatal);
        this.add(tombolBatal);

        tombolSimpan.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                tombolSimpanAction();
            }

            private void tombolSimpanAction() {
                Yudisium test = new Yudisium();
                test.setNama(getTextnama().getText());
                try {
                    test.setNim(getTextnim().getText());
                } catch (Exception ex) {
                    Logger.getLogger(FormMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
                }
                test.setTelpEmail(getTexttelpEmail().getText());
                test.setPeriode(getTextperiode().getText());
                test.setHari(getTexthari().getText());
                test.setTanggal(getTexttanggal().getText());
                if (getRadioTI().isSelected()) {
                    test.setProdi("TI");
                } else if (getRadioTM().isSelected()) {
                    test.setProdi("TM");
                } else if (getRadioTE().isSelected()) {
                    test.setProdi("TE");
                } else if (getRadioMAT().isSelected()) {
                    test.setProdi("MAT");
                }

                if (getDaftarNilai().isSelected() == true) {
                    test.setDaftarNilai("Ada");
                } else {
                    test.setDaftarNilai("Tidak Ada");
                }

                if (getNaskahTA().isSelected() == true) {
                    test.setNaskahTA("Ada");
                } else {
                    test.setNaskahTA("Tidak Ada");
                }

                if (getBebasPinjLab().isSelected() == true) {
                    test.setBebasPinjLab("Ada");
                } else {
                    test.setBebasPinjLab("Tidak Ada");
                }

                if (getBebasPinjDosen().isSelected() == true) {
                    test.setBebasPinjDosen("Ada");
                } else {
                    test.setBebasPinjDosen("Tidak Ada");
                }

                if (getKP().isSelected() == true) {
                    test.setKP("Ada");
                } else {
                    test.setKP("Tidak Ada");
                }

                if (getToefl().isSelected() == true) {
                    test.setToefl("Ada");
                } else {
                    test.setToefl("Tidak Ada");
                }

                if (getPengesahanTA().isSelected() == true) {
                    test.setPengesahanTA("Ada");
                } else {
                    test.setPengesahanTA("Tidak Ada");
                }

                if (getSistemPoin().isSelected() == true) {
                    test.setSistemPoin("Ada");
                } else {
                    test.setSistemPoin("Tidak Ada");
                }

                if (getRBM().isSelected() == true) {
                    test.setRBM("Ada");
                } else {
                    test.setRBM("Tidak Ada");
                }

                JOptionPane.showMessageDialog(null, "Data Tersimpan");
                PengendaliMahasiswa.tambahMahasiswa(test);
                PengendaliMahasiswa.tambahTabelMahasiswa(test);
            }
        });
        tombolBatal.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
    }
}
